import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
// ...
// 引入 element UI
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// 为 Element Plus 按需引入样式。
import ElementPlus from 'unplugin-element-plus/vite'


export default defineConfig({
  plugins: [vue(),
    AutoImport({
    resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    ElementPlus({
      // options
    }),
  ],
  resolve: {
    alias: {
      '~': path.resolve(__dirname, './'),
      '@': path.resolve(__dirname, 'src')
    },
  },
  // 配置代理
  server:{
    host: '0.0.0.0',
    port: 5173,
    // 是否开启 https
    https: false,
    proxy:{
      // https://i.maoyan.com
      '^/api':{
        target:`http://localhost:8080`,//替换的服务端地址
        changeOrigin:true,//开启代理，允许跨域
        rewrite:path=>path.replace(/^\/api/,'') // 设置重写的路径
      }
    }
  },
})
